package com.lw.tem.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.lw.tem.service.temservice.handler.TemBlockHandler;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/tem")
public class TemController {
   @PostMapping("/quick")
   @SentinelResource(value = "tem.quick",blockHandlerClass = TemBlockHandler.class,blockHandler = "handleQuickBlock")
   public String quick() {
       return "passed";
   }

    @PostMapping("/before")
    public String before() {
        return "brefore_passed";
    }
    @PostMapping("/after")
    public String after() {
        return "after_passed";
    }
    @PostMapping("/around")
    public String around() {
        return "around_passed";
    }
    @PostMapping("/query")
    public String query(@RequestHeader(value = "name1",defaultValue = "QQ")String name,@RequestHeader(value = "color") String color) {
        return "query_passed"+name+color;
    }
    @PostMapping("/cookie")
    public String cookie() {
        return "cookie_passed";
    }
    @PostMapping("/header")
    public String header(@RequestParam(value = "data") List<String> data,@RequestHeader(value = "X-Request-Color",defaultValue = "green") String color) {
        return "header_passed "+data+color;
    }
    @PostMapping("/special/")
    public String special() {
        return "special_passed";
    }
    @PostMapping("/test")
    public String test(@RequestHeader(value = "name1",defaultValue = "QQ")String name,@RequestHeader(value = "X-Request-Color",defaultValue = "blue") String color) {
        return "路径重新指定到了test"+name+color;
    }
}
